<?php
namespace Admin\Form;

use Zend\Form\Form;
use Zend\InputFilter;
use Zend\InputFilter\InputFilterProviderInterface;
use Zend\Form\Element\Csrf;
class ChangePassword extends Form implements InputFilterProviderInterface
{
    public function __construct()
    {
        parent::__construct('change-password');
    }

    public function init()
    {


        $this->add(array(
            'type' => 'Zend\Form\Element\Password',
            'name' => 'new-password',
            'options' => array(
                'label' => 'Mật khẩu mới: ',
            ),
        ));

        $this->add(array(
            'type' => 'Zend\Form\Element\Password',
            'name' => 'new-password-confirm',
            'options' => array(
                'label' => 'Nhắc lại: ',
            ),
        ));

        $this->add(array(
            'type' => 'Zend\Form\Element\Csrf',
            'name' => 'csrf',
        ));

        $this->add(array(
            'type' => 'Zend\Form\Element\Button',
            'name' => 'submit',
            'options' => array(
                'label' => 'Đổi mật khẩu',
            ),
            'attributes' => array(
                'type' => 'submit',
            ),
        ));
    }

    public function getInputFilterSpecification()
    {
        return array(

            'new-password' => array(
                'filters'  => array(
                    array('name' => 'Zend\Filter\StringTrim'),
                ),
                'validators' => array(
                    array(
                        'name' => 'Zend\Validator\StringLength',
                        'options' => array(
                            'min' => 5,
                            'max' => 63,
                        ),
                    ),
                ),
            ),
//             'new-password-confirm' => array(
//                 'filters'  => array(
//                     array('name' => 'Zend\Filter\StringTrim'),
//                 ),
//                 'validators' => array(
//                     array(
//                         'name' => 'Identical',
//                         'options' => array(
//                             'field' => 'new-password',
//                         ),
//                     ),
//                 ),
//             ),
        );
    }
}